from sklearn.neural_network import MLPClassifier
from sklearn.metrics import confusion_matrix,classification_report,accuracy_score,precision_score,recall_score,f1_score
import numpy as np
x=np.loadtxt('imgX.txt',delimiter=',')
y=np.loadtxt('labely.txt',delimiter=',')

model=MLPClassifier(hidden_layer_sizes=(100,150),max_iter=300)
model.fit(x,y)

print(model.score(x,y))
h=model.predict(x)

#常用参数
print('权重',model.coefs_)
print('截距',model.intercepts_)
print('循环次数',model.n_iter_)
print('感知机层数',model.n_layers_)
print('输出神经元个数',model.n_outputs_)
print('输出神经元激活函数',model.out_activation_)

print(confusion_matrix(y,h))
print(classification_report(y,h))
print(accuracy_score(y,h))

print(precision_score(y,h,average='micro'))
print(recall_score(y,h,average='micro'))
print(f1_score(y,h,average='micro'))